$(document).ready(function(){    
     $(".address_list input").click(function(){
        $(".address_list input").parent().removeClass("select")
        $(this).parent().addClass("select");        
        var id = $(this).val();
        $.ajax({
            type:"POST",
            url: "/member/order/confirm_order",
            data:"addid="+id,
            success: function(){
                alert("您选择了新的收货地址！将重新确认订单");
                location.reload();            
            }
        })
        
        //location.reload();
         });
     $(".address_list input").parent().removeClass("select")
     $(".address_list input:checked").parent().addClass("select");      
     history.go(1);
}); 

function exptype(id) {
    var pid = $("#"+id).val();
    var tid = $("#"+id).attr('data');
    //alert(tid);
    $.ajax({
        type:"POST",
        url: "/member/order/confirm_order",
        data:"expid="+tid+"&exptype="+pid,
        success: function(){
            location.reload();            
        }
    })
};
function addressshow(){
    $('#addressFrm').attr("action","/member/order/SaveAddress");
    $('.address_form').show();
}

function addresshide(){
    $('#addressFrm').attr("action","/member/order/SaveOrder");
    $('.address_form').hide();
}
function formsubmit(id){
    $('#addressFrm').attr("action","/member/order/SaveOrder");
    $('#'+id).submit();
}

function orderticket(price){
    var id =$('#order_ticket').val();
    if(id !== ''){     
     $.ajax({
        type:"POST",
        url: "/ajax/myticket",
        dataType:"json",
        data:"ticketid="+id+'&price='+price,      
        success: function(data){           
            if(data.errors==0){
                 alert(data.msg);
            }else{
                $("#ticket").html('-'+data.ticket);
                $("#totalprice").html(data.totalprice);
            }

        }
    })
    }else{
        $("#ticket").html('0');
        $("#totalprice").html(price);
    }
}

function favorable(price,fullsent){
    var id =$('#order_favorable').val();
    if(id == 1){
        $('#favorable_ticket').show();
        $('#favorable_fullsent').hide();
        $("#totalprice").html(price);
    }else if(id == 2){
        $('#favorable_ticket').hide();
        $('#favorable_fullsent').show();
        $.ajax({
            type:"POST",
            url: "/ajax/fullsent",
            dataType:"json",
            data:'price='+price,      
            success: function(data){           
                if(data.errors==0){
                     alert(data.msg);
                }else{                   
                    $("#totalprice").html(data.totalprice);
                }

            }
        });       
        $('#order_ticket').val(0);
        $("#ticket").html('0');       
    }else{
        $('#favorable_ticket').hide();
        $('#favorable_fullsent').hide();
        $("#totalprice").html(price);
        $('#order_ticket').val(0);
        $("#ticket").html('0'); 
    }
}